package org.jeecg.modules.compilation.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.compilation.dto.DepartmentDTO;
import org.jeecg.modules.compilation.service.impl.CiDepartmentServiceImpI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags="部门管理")
@RestController
@RequestMapping("/compilation/ciDepartment")
@Slf4j
public class CiDepartmentController {

	@Autowired
	private CiDepartmentServiceImpI ciDepartmentService;


//	/**
//	 * 部门更新按钮
//	 *
//	 */
//	@AutoLog(value = "部门更新按钮")
//	@ApiOperation(value="部门更新按钮", notes="部门更新按钮")
//	@PostMapping(value = "/updateDepartment")
//	public Result<String> updateDepartment( ) throws ParseException {
//		if( ciDepartmentService.updateDepartment() ){
//			return Result.OK("更新部门信息成功!");
//		}
//		return Result.error("更新部门信息成功!");
//	}

	/**
	 * web部门下拉框
	 *
	 */
	@AutoLog(value = "web部门下拉框")
	@ApiOperation(value="web部门下拉框", notes="web部门下拉框")
	@GetMapping(value = "/list")
	public Result<List<DepartmentDTO>> queryList( )  {
		Result<List<DepartmentDTO>> result = new Result<>();
		result.setResult( ciDepartmentService.queryList() );
		return result;
	}



	/**
	 * web部门编辑
	 *
	 */
	@AutoLog(value = "web部门编辑")
	@ApiOperation(value="web部门编辑", notes="web部门编辑")
	@PostMapping(value = "/editById")
	public Result<List<DepartmentDTO>> editById(@RequestBody DepartmentDTO dto)  {
		if ( ciDepartmentService.editById(dto) )
			return Result.ok("编辑成功");
		return Result.error("编辑失败");
	}

//	/**
//	 * 小程序部门展示
//	 *
//	 */
//	@AutoLog(value = "小程序部门展示")
//	@ApiOperation(value="小程序部门展示", notes="小程序部门展示")
//	@GetMapping(value = "/show")
//	public Result<List<DepartmentDTO>> show( @RequestParam(required = false) String isShow, @RequestParam(required = false) String title)  {
//		return Result.ok( ciDepartmentService.show(isShow,title) );
//	}


}
